package com.ff.neuropp.domain;

import java.sql.Time;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ff.neuropp.Dto.PageDto;
import com.ff.neuropp.util.DateSerializer;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@Entity
@Table(name = "t_resource", uniqueConstraints = {@UniqueConstraint(columnNames="id")})
/**
 * Resource表
 * @author sun_weiwu
 *
 */
public class Resource  extends PageDto{
	 private static final long serialVersionUID = 1L;
	 
	   @Id
	    @GeneratedValue(strategy = GenerationType.IDENTITY)
	    private int id;
	 

	    @Column(name = "resource_name", columnDefinition = "varchar(100) COMMENT '资源名称'")
	    @ApiModelProperty(value = "资源名称")
	    private String resourceName; 
	    
	    @Column(name = "resource_about", columnDefinition = "varchar(500) COMMENT '资源简介'")
	    @ApiModelProperty(value = "资源简介 ")
	    private String resourceAbout ; 
	    
	    @Column(name = "resource_desc", columnDefinition = "varchar(2000) COMMENT '资源描述'")
	    @ApiModelProperty(value = "资源描述 ")
	    private String resourceDesc ; 
	    
	    @Column(name = "resource_title", columnDefinition = "varchar(2000) COMMENT '资源标题'")
	    @ApiModelProperty(value = "资源标题 ")
	    private String resourceTitle ;

		@Column(name = "resource_time", columnDefinition = "Time COMMENT '资源时间'")
		@ApiModelProperty(value = "资源时间(具体到时分) ")
		@DateTimeFormat(pattern = "HH:mm:ss")
		@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="HH:mm:ss")
		private Time resourceTime ;

		@Column(name = "resource_date", columnDefinition = "Date COMMENT '资源日期'")
		@ApiModelProperty(value = "资源日期 ")
		@DateTimeFormat(pattern = "yyyy-MM-dd")
		@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
		private Date resourceDate ;
	    
	    
	    @Column(name = "resource_local", columnDefinition = "varchar(100) COMMENT '资源地点'")
	    @ApiModelProperty(value = "资源地点 ")
	    private String resourceLocal ;
	    
	    
	    @OneToOne
		@JoinColumn(name = "career_id")
		@ApiModelProperty(value = "职业简介Id")
		private Career career;
	    
	    
//	    @Column(name = "file_url", columnDefinition = "varchar(100) COMMENT '文件url多个'")
//	    @ApiModelProperty(value = "文件url多个 ")
//	    private String fileUrl ;

		@OneToMany(cascade = {CascadeType.ALL})
		@JoinColumn(name = "resource_id")
		@ApiModelProperty(value = "课件地址")
		private List<FileDto> fileList;
	    
	    
        //文章list
	    @OneToMany(cascade = {CascadeType.DETACH})
	    @JoinColumn(name = "resource_id")
	    private List<Article> articleList;
	    
	    
	    //操作时间
	    @Column(updatable = false)
	    @org.hibernate.annotations.CreationTimestamp
	    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	    @JsonSerialize(using = DateSerializer.class)
	    private Date create_date;
	    
	    @Column(name = "update_time", columnDefinition = "datetime COMMENT '更新时间'")
	    private Date updateTime;
	    
}
